/**
 * Created by Administrator on 2017/4/2 0002.
 */
var Easy=
{
    CreateJSONGroup:function (group,parent) {
        var ob={};
        for(var name in group)
        {
            var sp=Easy.CreateJSONSprite(group,name,1);
            ob[name]=sp;
            if(parent)
            {
                parent.addChild(sp);
            }
        }
        return ob;
    },

    CreateJSONSprite:function(jsonGroup,name,_alpha)
    {
        var url=jsonGroup[name].url;
        var _x=jsonGroup[name].x;
        var _y=jsonGroup[name].y;
        console.log(jsonGroup,name,url)
        var sp=new PIXI.Sprite(resource[url].texture);
        sp.x=_x;
        sp.y=_y;
        sp.anchor.set(0.5,0.5);
        sp.alpha=_alpha;
        return sp;
    },
    CreateSprite:function(url,_x,_y,ax,ay,_alpha)
    {
        //var ax=arguments[3] ? arguments[3] : 0.5;
        //var ay=arguments[4] ? arguments[4] : 0.5;
        //var _alpha=arguments[5] ? arguments[5] : 1;
        console.log('CreateSprite:',url)
        var sp=new PIXI.Sprite(resource[url].texture);
        sp.x=_x;
        sp.y=_y;
        sp.anchor.set(ax,ay);
        sp.alpha=_alpha;
        return sp;
    },
    CreateMC:function (length,head,tail,x,y,width,height,anchorX,anchorY) {
        var arr_texture=[];
        for(var i=0;i<length;i++)
        {
            var str='';
            if(i<10)
            {
                str='00'+i.toString();
            }
            else if(i<100)
            {
                str='0'+i.toString();

            }
            else
            {
                str=i.toString();
            }
            console.log(head+str+tail)
            var texture = resource[head+str+tail].texture;
            arr_texture.push(texture);
        }
        var mc=new PIXI.extras.AnimatedSprite(arr_texture);
        mc.anchor.set(anchorX,anchorY);
        mc.width=width;
        mc.height=height;
        mc.x=x;
        mc.y=y;
        // mc.gotoAndPlay(1);
        return mc;
    },
    CreateText:function(text,_x,_y,fontSize,textWidth,color,_dropShadow,_align)
    {
        var _dropShadow=arguments[6] ? arguments[6] : false;
        var _align=arguments[7] ? arguments[7] : 'center';
        var style={
            fontSize: fontSize,
            textWidth:textWidth,
            fill:color,
            //fill: [color, color], // gradient��#000000
            dropShadow: _dropShadow,
            dropShadowColor: '#000000',
            align: _align
        }
        var myText = new PIXI.Text(text,style);
        myText.x=_x;
        myText.y=_y;

        return myText;
    }
}